#-*- coding:utf-8 -*-

from .settings_common import *

# django 容器（如 gunicorn, cherrypy） web服务地址
WEB_SERVER_LISTEN_ADDR = ('127.0.0.1',8080)

CELERY_BROKER_URL = 'amqp://yjyx:sdfsdf@10.25.57.1/yjyx'
MQ_MGR_URL = '127.0.0.1:15672'
MQ_MGR_USER = 'nijie'
MQ_MGR_PASSWD = '123456'
MQ_CHORD_VHOST = 'nijie'
MQ_CHORD_QUEUE = 'paperanalyzer'
CELERY_REDIS_PASSWD = ''

GUNICORN_WORKER_NUMBER =  multiprocessing.cpu_count()

# Database

DATABASES['default']['NAME'] = 'yjyx'
DATABASES['default']['USER'] = 'yjyx_real'
DATABASES['default']['PASSWORD'] = '__________'
DATABASES['default']['HOST'] = '10.24.26.179'

DEBUG=False





# 支付宝支付设置

DOMAIN_URL = "https://www.zgyjyx.com"

ALIPAY_CALLBACK_ADDR = 'www.zgyjyx.com'

class alipay_settings():

    # 安全检验码，以数字和字母组成的32位字符
    ALIPAY_KEY =  '__________' 

    # 合作身份者ID，以2088开头的16位纯数字
    ALIPAY_PARTNER = '2088121849798485' #'2088002427135107'

    # 签约支付宝账号或卖家支付宝帐户
    ALIPAY_SELLER_EMAIL =  'yjyx@zgyjyx.com' #'jcyrss@163.com'

    ACCOUNT_NAME =  '浙江亿教亿学网络科技有限公司' #商家账户名

    ALIPAY_INPUT_CHARSET = 'utf-8'

    ALIPAY_SIGN_TYPE = 'MD5'
    ALIPAY_MOBILE_SIGN_TYPE = 'RSA'
    ALIPAY_SHOW_URL=''
    # 访问模式,根据自己的服务器是否支持ssl访问，若支持请选择https；若不支持请选择http
    ALIPAY_TRANSPORT='https'

    # 付完款后跳转的页面（同步通知） 要用 http://格式的完整路径，不允许加?id=123这类自定义参数
    ALIPAY_RETURN_URL_STUDENT_BUY_PRODUCT='http://%s/student/payment/alipay_buy_product_result.html' % ALIPAY_CALLBACK_ADDR

    # 交易过程中服务器异步通知的页面 要用 http://格式的完整路径，不允许加?id=123这类自定义参数
    ALIPAY_NOTIFY_URL_STUDENT_BUY_PRODUCT='http://%s/api/payment/ali/student_buy_product_notify' % ALIPAY_CALLBACK_ADDR
    ALIPAY_MOBILE_NOTIFY='http://%s/api/payment/ali/mobilepaynotify' % ALIPAY_CALLBACK_ADDR


class wx_settings():
    APP_ID     = "wxe062e736b5bc8322"
    APP_SECRET = "__________"
    MCH_ID     = "1336170201"                        # 商户号
    MCH_SECRET = "__________"  # 商户Key
    MCH_SSL_CERT_PATH   = "/home/yjyx/yijiao_src/yijiao_main/cert/apiclient_cert.pem"    # 商户证书路径
    MCH_SSL_KEY_PATH    = "/home/yjyx/yijiao_src/yijiao_main/cert/apiclient_key.pem"  # 商户私钥Key
    # 微信认证重定向回域名， 在微信开发平台 开发者中心->接口权限表->网页服务->网页授权获取用户基本信息->OAuth2.0网页授权:授权回调页面域名
    WX_AHTH_REDIRECT_DOMAIN = 'www.zgyjyx.com'
    TEMPLATE_ID_DETAIL = {
        1: {
            'id': 1,
            'template_id': 'yBG-JVBUh-Z921sdPdB5NOk0Q1Ckubn-gT9T3HcIwP8',
        },
        2: {
            'id': 2,
            'template_id': '-T6QMvekcq0s0ky53IZOOA6AwendPOqUVgdYuHGMBWs',
        }
    }


# 七牛云设置

QINIU_accessKey          = 'cgPnimqdk-NnJx7FhwsShV7iArJFp_Z1iOl4Vjyy'
QINIU_secretKey          = '__________'
QINIU_videoBucketName    = 'yjyx-web-video'
QINIU_videoBucketDomain  = 'http://cdn-web-video.zgyjyx.com/'
QINIU_imgBucketName      = 'yjyx-web-img'
QINIU_imgBucketDomain    = 'http://cdn-web-img.zgyjyx.com/'
QINIU_textBucketName     = 'yjyx-web-static'
QINIU_textBucketDomain   = 'http://cdn-web-static.zgyjyx.com/'




CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': [
            '10.25.57.1:11211',
        ],
        'TIMEOUT':  1800
    },

    'onedaycache': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': [
            '10.25.57.1:11211',
        ],
        'TIMEOUT':  86400
    }
}






# FATAL = CRITICAL = 50 ERROR = 40  WARN = WARNING = 30 INFO = 20 DEBUG = 10 NOTSET = 0
LOG_LEVEL = 'INFO'

django_sys_log_setting = {
                            'handlers': ['django_file'],
                            'level': LOG_LEVEL,
                            'propagate': False,
                         }

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse',
        },
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        },
    },
    'formatters': {
        'verbose': {
            'format': '%(asctime)s %(message)s',
            'datefmt': '%m%d_%H:%M:%S'
        },
        'simple': {
            'format': '%(message)s'
        },
        'detail': {
            'format': '%(asctime)s %(filename)s [line:%(lineno)d] %(levelname)s %(message)s'
        },
    },
    'handlers': {
        'null': {
            'class': 'logging.NullHandler',
        },
        'console': {
            'level': LOG_LEVEL,
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'django_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/django.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'mgr_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/mgr.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },

        'teacher_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/teacher.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },

        'student_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/student.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'parent_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/parent.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'datamodel_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/model.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'stats_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/stats.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'alipay_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/alipay.log',
            'maxBytes' : 1024*1024*3, # 3MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'push_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/push.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'sms_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/sms.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 50,
            'formatter': 'verbose'
        },
        'version_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/version.log',
            'maxBytes' : 1024*1024*10, # 10MB
            'backupCount' : 20,
            'formatter': 'verbose'
        },
        'paperwork_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',#'logging.FileHandler',
            'filename': '/home/yjyx/log/paperwork.log',
            'maxBytes': 1024*1024*10, # 10MB
            'backupCount': 20,
            'formatter': 'verbose'
        },
        'danger_file': {
            'level': LOG_LEVEL,
            'class': 'logging.handlers.RotatingFileHandler',  # 'logging.FileHandler',
            'filename': '/home/yjyx/log/danger.log',
            'maxBytes': 1024 * 1024 * 10,  # 10MB
            'backupCount': 20,
            'formatter': 'detail'
        },
    },

    'loggers': {
        'django': {
            'handlers': ['console'],
            'level': LOG_LEVEL,
        },
        'django.request':     django_sys_log_setting,
        'django.security':    django_sys_log_setting,
        'py.warnings':        django_sys_log_setting,
        'django.db.backends': django_sys_log_setting,

        'mgr': {
            'handlers': ['mgr_file'],
            'level': LOG_LEVEL,
        },

        'teacher': {
            'handlers': ['teacher_file'],
            'level': LOG_LEVEL,
        },

        'student': {
            'handlers': ['student_file'],
            'level': LOG_LEVEL,
        },
        'parent': {
            'handlers': ['parent_file'],
            'level': LOG_LEVEL,
        },

        'datamodel': {
            'handlers': ['datamodel_file'],
            'level': LOG_LEVEL,
        },

        'stats': {
            'handlers': ['stats_file'],
            'level': LOG_LEVEL,
        },

        'alipay': {
            'handlers': ['alipay_file'],
            'level': LOG_LEVEL,
        },
        'push': {
            'handlers': ['push_file'],
            'level': LOG_LEVEL,
        },
        'sms': {
            'handlers': ['sms_file'],
            'level': LOG_LEVEL,
        },
        'version': {
            'handlers': ['version_file'],
            'level': LOG_LEVEL,
        },
        'paperwork': {
            'handlers': ['paperwork_file'],
            'level': LOG_LEVEL,
        },
        'danger': {
            'handlers': ['danger_file'],
            'level': LOG_LEVEL,
        },
    }
}
ES_URL = "http://10.132.2.251:9200/"
